*******************************************************************************************************************************
*******************************************************************************************************************************
* Documentation for Reproduction of
* Pedulla 2011 TESS Survey Experiment
* TESS Race Discrimination Meta-Analysis
* Stata version 15
* Data available here: http://www.tessexperiments.org/data/pedulla170.html
*******************************************************************************************************************************
*******************************************************************************************************************************

* use "TESS2 085 - Pedulla_Client.dta", clear
set more off

*******************************************************************************************************************************
*** Racial groups
*******************************************************************************************************************************

tab PPETHM
gen whiteR = PPETHM
recode whiteR (2/5=0)
tab PPETHM whiteR
gen blackR = PPETHM
recode blackR (1 3/5=0) (2=1)
tab PPETHM blackR
gen hispnR = PPETHM
recode hispnR (1/3 5=0) (4=1)
tab PPETHM hispnR

*******************************************************************************************************************************
*** Treatments
*******************************************************************************************************************************

tab XTESS085
gen Twhite = 0
gen Tblack = 0
gen Tgay = 0
gen Tfemale = 0
gen Tmasculine = 0
gen Tfeminine = 0
replace Twhite = 1 if XTESS085==1 | XTESS085==3 | XTESS085==5 | XTESS085==7 | XTESS085==9
replace Tblack = 1 if XTESS085==2 | XTESS085==4 | XTESS085==6 | XTESS085==8 | XTESS085==10
replace Tgay = 1 if XTESS085==9 | XTESS085==10
replace Tfemale = 1 if XTESS085==3 | XTESS085==4
replace Tmasculine = 1 if XTESS085==5 | XTESS085==6
replace Tfeminine = 1 if XTESS085==7 | XTESS085==8

*******************************************************************************************************************************
*** Outcome variables
*******************************************************************************************************************************

tab1 Q1-Q10
recode Q1-Q10 (-1=.)
tab1 Q1-Q10

tab Q1
gen salary = Q1
replace salary = 80000 if salary > 80000 & salary !=.
tab salary
egen salary_std = std(salary)

tab Q2
gen hire01 = Q2
recode hire01 (2=0)

alpha Q3_a Q3_b Q3_c Q3_d Q4_a Q4_b Q4_c Q4_d Q5_a Q5_b Q5_c Q5_d Q6_a Q6_b Q6_c Q6_d
alpha Q3_a Q3_b Q3_c Q3_d Q4_a Q4_b Q4_c Q4_d Q5_a Q5_b Q5_c Q5_d Q6_a Q6_b Q6_c Q6_d, item
alpha Q3_a Q3_b Q3_c Q3_d Q4_a Q4_b Q4_c Q4_d Q5_a Q5_b Q5_c Q5_d Q6_a Q6_b Q6_c Q6_d, min(9) std item gen(character)
egen character_std = std(character)
pwcorr Q3_a character_std

alpha salary_std Q3_a Q3_b Q3_c Q3_d Q4_a Q4_b Q4_c Q4_d Q5_a Q5_b Q5_c Q5_d Q6_a Q6_b Q6_c Q6_d, min(9) std item

alpha salary_std hire01 Q3_a Q3_b Q3_c Q3_d Q4_a Q4_b Q4_c Q4_d Q5_a Q5_b Q5_c Q5_d Q6_a Q6_b Q6_c Q6_d, min(9) std item gen(ALPHA)

sum ALPHA if whiteR==1
di r(sd)
gen ov_white_std = ALPHA/r(sd) if whiteR==1

sum ALPHA if blackR==1
di r(sd)
gen ov_black_std = ALPHA/r(sd) if blackR==1

sum ALPHA if hispnR==1
di r(sd)
gen ov_hispn_std = ALPHA/r(sd) if hispnR==1

*******************************************************************************************************************************
*** Racial manipulation check
*******************************************************************************************************************************

tab XTESS085 Q8
gen MCrace = 0
replace MCrace = 1 if (XTESS085==1 & Q8==1) | (XTESS085==2 & Q8==2) | (XTESS085==3 & Q8==1) | (XTESS085==4 & Q8==2) | (XTESS085==5 & Q8==1)  | (XTESS085==6 & Q8==2) |  (XTESS085==7 & Q8==1) | (XTESS085==8 & Q8==2) | (XTESS085==9 & Q8==1) |  (XTESS085==10 & Q8==2)
tab XTESS085 Q8 if MCrace==1
tab XTESS085 Q8 if MCrace==0

tab MCrace 
tab MCrace if whiteR==1
tab MCrace if blackR==1

*******************************************************************************************************************************
*** Main regressions [Unweighted]
*******************************************************************************************************************************

reg ov_white_std Tblack Tfemale Tgay Tmasculine Tfeminine if whiteR==1
reg ov_black_std Tblack Tfemale Tgay Tmasculine Tfeminine if blackR==1
reg ov_hispn_std Tblack Tfemale Tgay Tmasculine Tfeminine if hispnR==1
